home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 127 / PC Guia 127.iso / Software / Produtividade / OpenOffice.org 2.0.1 / openofficeorg1.cab / Writer.xba < prev    next >
Extensible Markup Language  |  2002-09-17  |  3KB  |  71 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
  3. <script:module xmlns:script="http://openoffice.org/2000/script" script:name="Writer" script:language="StarBasic">REM  *****  BASIC  *****
  4.  
  5.  
  6. Sub ConvertWriterTables()
  7. Dim CellString as String
  8. Dim oParagraphs as Object
  9. Dim oPara as Object
  10. Dim i as integer
  11. Dim sCellNames()
  12. Dim oCell as Object
  13.     oParagraphs = oDocument.Text.CreateEnumeration
  14.     While oParagraphs.HasMoreElements
  15.         oPara = oParagraphs.NextElement
  16.         If NOT oPara.supportsService("com.sun.star.text.Paragraph") Then
  17.             ' Note: As cells might be splitted or merged
  18.             ' you cannot refer to them via their indices
  19.             sCellNames = oPara.CellNames
  20.             For i = 0 To Ubound(sCellNames)
  21.                 If sCellNames(i) <> "" Then
  22.                     oCell = oPara.getCellByName(sCellNames(i))
  23.                     If CheckFormatType(oCell) Then
  24.                         SwitchNumberFormat(oCell, oFormats, sEuroSign)
  25.                         ModifyObjectValuewithCurrFactor(oCell)
  26.                     End If
  27.                 End If
  28.             Next
  29.         End If
  30.     Wend
  31. End Sub
  32.  
  33.  
  34. Sub ModifyObjectValuewithCurrFactor(oDocObject as Object)
  35.     oDocObjectValue = oDocObject.Value
  36.     oDocObject.Value = oDocObjectValue/CurrFactor
  37. End Sub
  38.  
  39.  
  40. Sub ConvertTextFields()
  41. Dim oTextFields as Object
  42. Dim oTextField as Object
  43. Dim FieldValue
  44. Dim oDocObjectValue as double
  45. Dim InstanceNames(500) as String
  46. Dim CurInstanceName as String
  47. Dim MaxIndex as Integer
  48.     MaxIndex = 0
  49.     oTextfields = oDocument.getTextfields.CreateEnumeration
  50.     While oTextFields.hasmoreElements
  51.         oTextField = oTextFields.NextElement
  52.         If oTextField.PropertySetInfo.HasPropertybyName("NumberFormat") Then
  53.             If CheckFormatType(oTextField) Then
  54.                 If oTextField.PropertySetInfo.HasPropertybyName("Value") Then
  55.                     If Not oTextField.SupportsService("com.sun.star.text.TextField.GetExpression") Then
  56.                         oTextField.Content = CStr(Round(oTextField.Value/CurrFactor,2))
  57.                     End If
  58.                 ElseIf oTextField.TextFieldMaster.PropertySetInfo.HasPropertyByName("Value") Then
  59.                     CurInstanceName = oTextField.TextFieldMaster.InstanceName
  60.                     If Not FieldinArray(InstanceNames(), MaxIndex, CurInstanceName) Then
  61.                         oTextField.TextFieldMaster.Content = CStr(Round(oTextField.TextFieldMaster.Value/CurrFactor,2))
  62.                         InstanceNames(MaxIndex) = CurInstanceName
  63.                         MaxIndex = MaxIndex + 1
  64.                     End If
  65.                 End If
  66.                 SwitchNumberFormat(oTextField, oFormats, sEuroSign)
  67.             End If
  68.         End If
  69.     Wend
  70.     oDocument.GetTextFields.refresh()
  71. End Sub</script:module>